package test3.dao;

import org.junit.Test;
import test3.bean.Employee;
import test3.bean.EmployeeForQuery;
import test3.dao.impl.EmployeeDaoImpl;
import test3.file.FileModel;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TestEmployeeDao {

    private EmployeeDaoImpl employeeDao=EmployeeDaoImpl.createEmployeeDao();
    private FileModel model=new FileModel();

    @Test
    public void testQueryAllList(){
        System.out.println(employeeDao.queryAllByList());
    }

    @Test
    public void testInputFile(){
        System.out.println(model.inputAllEmployee());
    }

    @Test
    public void testOutput() throws IOException {
        model.outputAllEmployee(new HashMap<>());
    }

    @Test
    public void testQueryById(){
        System.out.println(employeeDao.queryById(10));
    }

    @Test
    public void testInsert(){
        employeeDao.insertOrUpdate(new Employee(2,"jia",0,20));
        List<Employee> employees=employeeDao.queryAllByList();
        System.out.println(employees);
    }

    @Test
    public void testQueryByName(){

        employeeDao.insertOrUpdate(new Employee(2,"jia",0,20));
        employeeDao.insertOrUpdate(new Employee(3,"qie",1,16));
        employeeDao.insertOrUpdate(new Employee(4,"bu",0,18));
        employeeDao.insertOrUpdate(new Employee(5,"xiang",0,22));
        employeeDao.insertOrUpdate(new Employee(6,"hua",1,22));
        employeeDao.insertOrUpdate(new Employee(7,"kai",0,22));

        EmployeeForQuery query=new EmployeeForQuery(1,"jia",0,20,16,20);
        System.out.println(employeeDao.queryAllByList());
    }

    @Test
    public void testNullPoint(){
        Map<Integer,Employee> map=new HashMap<>();

        System.out.println(map.get(1));
    }
}
